/**
 * 载入提示
 */
Fw.LoadMask = Fw.extend(Fw.Component, {
    /**
     * 初始化组件
     */
    initComponent: function() {
        Fw.LoadMask.superclass.initComponent.call(this);
        //
    },
    /**
     * 初始化事件
     */
    initEvents: function() {
    },
    /**
     * 初始化HTML模版
     */
    initTpl: function() {
        var id = Fw.id();
        var tpl = [
            '<div id="${id}" class="mask" style="position:fixed;">',
               '<span id="${id}-glyph" class="glyph glyph-spinner"></span>',
            '</div>'
        ];
        $('html').append(Fw.template(tpl, {
            id: id
        }));
        this.el = $('#' + id);
        this.glyph = $('#' + id + '-glyph');
    },
    /**
     * 隐藏
     */
    hide: function(){
        if(this.hidden === false){
            this.glyph.removeClass('enable');
            this.el.hide();
            this.hidden = true;
        }
    },
    /**
     * 显示
     */
    show: function(owner){
        owner = owner || this.owner;
        var width = owner.innerWidth();
        var height = owner.innerHeight();
        var position = owner.offset();
        this.glyph.addClass('enable');
        this.el.width(width).height(height).css(position).show();
        this.hidden = false;
    }
});

/**
 * 公共等待层 
 */
Fw.util.LoadMask = new Fw.LoadMask({
    owner: $('html'),
    /**
     * 显示
     */
    show: function(owner){
        var width, height, position;
        if(owner){
            width = owner.innerWidth();
            height = owner.innerHeight();
            position = owner.offset();
        }
        else{
            width = '100%';
            height = '100%';
            position = {
                top: 0,
                left: 0
            };
        }
        this.glyph.addClass('enable');
        this.el.width(width).height(height).css(position).show();
        this.hidden = false;
    }
});
